<?php
	if(isset($_POST['connexion']) && $_POST['connexion'] == 'ok'){
		if(isset($_POST['login']) && !empty($_POST['login'])){
			if(isset($_POST['pwd']) && !empty($_POST['pwd'])){
				$try = User::getFromLogin($_POST['login'], $_POST['pwd']);
				if($try != null){
					$_SESSION['user'] = $try->getId();
					$user = $try;
				}else{
					$error='Login ou mot de passe invalide.';
				}
			}else{
				$error='Login ou mot de passe invalide.';
			}
		}else{
			$error='Login ou mot de passe invalide.';
		}
	}
	
	if(isset($user) && !empty($user)){
		include('compte.html');
	}else{
		include('identification.html');
	}
?>